package pers.litao.bit.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.litao.bit.commons.entities.user.InformationEntity;
import pers.litao.bit.commons.utils.R;
import pers.litao.bit.commons.utils.SysUtil;
import pers.litao.bit.user.service.InformationService;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 李涛
 * @date 2021-01-03 13:59
 */
@RestController
@RequestMapping("/user/information")
public class InformationController {
    @Autowired
    private InformationService informationService;

    /**
     * 保存资讯
     *
     * @param informationEntity
     * @param request
     * @return
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    public R save(@RequestBody InformationEntity informationEntity, HttpServletRequest request){
        return informationService.saveInformation(informationEntity, SysUtil.getLoginUserInfo(request));
    }
    @RequestMapping("/list/{page}")
    public R getInformation(@PathVariable("page") Long page){
        return informationService.getList(page);
    }
    @RequestMapping("/init")
    public R init(){
//        return informationService.init();
        return R.ok();
    }
}
